import { Table } from 'antd';
import https from "../service/http";
import { React, useState, useEffect } from 'react';


const SchoolListTable = () => {

    const [Teacher, setTeacher] = useState([]);
    useEffect(() => {
        https('Teacher_list/getAll', "get", res => {
            var tName = []
            // console.log(res)
            for (var i = 0; i < res.data.length; i++) {
                tName.push(res.data[i].school_name)
            }
            setTeacher(tName)
        });
    }, []);
    useEffect(() => { },
        [Teacher]);

    const columns = [];
    const title = ['序号', '地区', '学校名称', '合计', '通知', '公告', '活动', '家园任务', '缴费通知', '选课通知', '作业', '请假', '发布相册', '评价', '投票', '带药提醒'];
    const dataIndex = ['key', 'region', 'schoolName', 'total', 'notice', 'Notice', 'activity', 'task', 'pay', 'Course', 'tasks', 'leave', 'pic', 'evaluate', 'vote', 'remind',];
    const width = [120, 200, 200, 200, 120, 120, 120, 120, 120, 120, 120, 120];
    for (let i = 1; i <= title.length; i++) {
        columns.push({
            title: title[i - 1],
            dataIndex: dataIndex[i - 1],
            width: width[i - 1],
        });
    }

    const data = [];
    for (let i = Teacher.length; i > 0; i--) {
        data.push({
            key: Teacher.length - i + 1,
            region: '地区' + [Teacher.length - i + 1],
            schoolName: Teacher[Teacher.length - i],
            total: i * 12,
            notice: i,
            Notice: i,
            activity: i,
            task: i,
            pay: i,
            Course: i,
            tasks: i,
            leave: i,
            pic: i,
            evaluate: i,
            vote: i,
            remind: i,
        });
    }
    return (
        <Table
            className='Table'
            columns={columns}
            dataSource={data}
            bordered
            size="middle"
            scroll={{
                // x: 'calc(1000px + 50%)',
                y: 400,
            }}
        />
    )

};


export default SchoolListTable;